//======================================================================================
//  Notes:Use this command to anonymously check out the latest project source code:
//  Non-members may check out a read-only working copy anonymously over HTTP.
//  http://YHQCodingWsp.googlecode.com/svn/trunk/
//
//  Author:		Kevin Yang
//  Email:		Bigearrabbit@qq.com
//
//  DATE:		2013-4-22
//
//  File Name:	YHQCAAToolsPlugin.cpp
//
//  Notes:
//
//======================================================================================

//Local library
#include "YHQCAAToolsPlugin.h"
#include "YHQDockWidgetCAATools.h"


//YHQCodingCore Library
#include "YHQCodingCore.h"
#include "YHQDockWidget.h"
//#include "YHQMainWindow.h"

//Qt Library
#include <QDir>
#include <QStringList>
#include <QFileInfo>
#include <QString>
#include <QList>
#include <QFile>
#include <QtPlugin>
#include <QDebug>

//----------------------------------------------------
YHQCAAToolsPlugin::YHQCAAToolsPlugin()
{

}
//----------------------------------------------------
YHQCAAToolsPlugin::~YHQCAAToolsPlugin()
{
}
//----------------------------------------------------
YHQDockWidget * YHQCAAToolsPlugin::LoadYHQDockWidget(QString * opErrMsg)
{
    QString errMsg;//error message

    //check out main window
    YHQMainWindow * pMainWindow = YHQCodingCore::GetMainWindowPtr();//get main window
    YHQDockWidgetCAATools * pdockWidget = NULL;//dock widget
    if(!pMainWindow)
    {
        errMsg = "Can not get MainWindow";
        goto LabelErrMsg;//error treatement
    }
    else
    {
        pdockWidget= new YHQDockWidgetCAATools(pMainWindow);//new dock widget
        pMainWindow->addDockWidget(Qt::LeftDockWidgetArea,pdockWidget);//add to main window
        pdockWidget->setWindowTitle("CAA Tools");//setWindowTitle

        pdockWidget->SetOutsideTextEditPtr(pMainWindow->GetTextEditPtr());//set editor
        return pdockWidget;//ok
    }
LabelErrMsg:

    if(opErrMsg) * opErrMsg = errMsg;//copy value
    return pdockWidget;//failed

}
//----------------------------------------------------
